#include <workflow/Workflow.h> 
#include <workflow/WFFacilities.h>
#include <workflow/WFTaskFactory.h>
#include <workflow/HttpUtil.h>
#include <unistd.h>
#include <signal.h>
#include <ctime>
#include <iostream>
using std::cerr;
using std::cout;
// 定义一个全局变量
static WFFacilities::WaitGroup waitGroup(1);
void sighandler(int signum)
{
	waitGroup.done();
}

void timerCallback(WFTimerTask * task){
	time_t now = time(nullptr);
	cerr << "timenow = " << ctime(&now);

	WFTimerTask* nextTask = WFTaskFactory::create_timer_task(3, 0, timerCallback);//不是递归
	series_of(task)->push_back(nextTask); 
}


int main()
{
	signal(SIGINT, sighandler);
	
	time_t now = time(nullptr);
	cerr << "timenow = " << ctime(&now);

	WFTimerTask* timerTask = WFTaskFactory::create_timer_task(3, 0, timerCallback);
	timerTask->start();
	
	waitGroup.wait();
	cout << "finished!\n"; // 不使用std::endl
}